#include <stdio.h>

int nums[999];
int size=0,move=0;

void input(){
    scanf("%d", &size);
    for (size_t i = 0; i < size; i++)
    {
        scanf("%d", &nums[i]);
    }
    scanf("%d", &move);
}
void output(){
    for (size_t i = 0; i < size; i++)
        printf("%d ", nums[i]);
}

void handle(){
    int tempNums[999];
    //新数组赋值
    for (size_t i = 0; i < size; i++)
    {
        tempNums[i] = nums[i];
    }

    //交换
    for (size_t j = 0; j < size;j++)
    {
        if(move==0){
            break;
        }else{
            if(move>=size){
                move = move - size;
                nums[move] = tempNums[j];
            }else{
                nums[move] = tempNums[j];
            }
        }
        move++;
    }
    
}

int main(int argc, char *argv[]) {

    input();
    handle();
    output();

    return 0;
}



